package com.wolfheader.wolfgame.controller.admin;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.wolfheader.wolfgame.dao.admin.ProductDao;
import com.wolfheader.wolfgame.service.admin.AdminService;

@Controller("adminProductController")
@RequestMapping("/admin/product")
public class ProductController {

	private static final String template_url = "admin/product";

	@Autowired
	private ProductDao productDao;

	@Resource(name = "adminServiceImpl")
	private AdminService adminService;

	@RequestMapping(value = "/list", method = RequestMethod.GET)
	public String login(HttpServletRequest request, ModelMap map) {
		map.addAttribute("menu1", "product");
		map.addAttribute("menu2", "list");
		map.addAttribute("products", productDao.findAll());
		return template_url + "/list";
	}

	@RequestMapping(value = "/add", method = RequestMethod.GET)
	public String add(HttpServletRequest request, ModelMap map) {
		map.addAttribute("menu1", "product");
		map.addAttribute("menu2", "add");
		return template_url + "/add";
	}
}
